<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>物流管理</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="../../lib/layui-v2.6.3/css/layui.css" media="all" rel="stylesheet">
    <link href="../../css/public.css" media="all" rel="stylesheet">
    <link href="../../css/diy/form1.css" rel="stylesheet">
    <script src="../../lib/layui-v2.6.3/layui.js"></script>
    <script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
    <script src="../../js/template-web.js"></script>
    <script src="../../js/lay-module/layuimini/miniTab.js"></script>
    <script src="../../frontstatic/js/notify.js"></script>
    <script src="../../frontstatic/js/notify_stand.js"></script>
    <style type="text/css">
        body{
            background-color: #FFFFFF;
        }
    </style>
</head>
<body>
<div>
    <button class="layui-btn layui-btn-normal layui-btn-sm" id="BrandaddBtn" type="button" style="margin-left: 1420px;margin-top: 25px"><i class="layui-icon"></i></button>
    <div style="width: 1400px">
        <table class="layui-table" id="logisticsTable" lay-filter="logisticsTable"></table>
    </div>
</div>
</body>
<script id="barlist" type="text/html">
    <a class="layui-btn layui-btn-primary layui-border-red layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
    var notify;
    layui.use(['notify'],function(){
        notify=layui.notify;
    })
    layui.use(['table'], function () {
        var table = layui.table;
        table.render({
            elem: '#logisticsTable'
            , method: 'post'
            , title: '地址信息表格'
            , url: '/Logistics/page' //数据接口
            , contentType: 'application/json'
            , page: {theme:'#1E9FFF'} //开启分页
            , limit: 10
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.records//解析数据列表
                };
            }
            , cols: [[
                {type: 'numbers', title: '序号'}
                , {field: 'name', title: '物流公司名称'}
                , {field: 'phone', title: '客服电话'}
                , {field: 'ceateTime', title: '添加时间'}
                , {fixed: 'right', toolbar: '#barlist',width: 200,title: '操作'}
            ]]
        });
        $("#BrandaddBtn").on('click', function () {
            layer.open({
                type: 2,
                title: '物流公司添加',
                shadeClose: true,
                shade: 0.8,
                anim: 4,
                area: ['1000px', '500px'],
                content: 'add_logistics.html',
                end:function() {
                    location.reload();
                }
            });
        })
        //监听行工具事件
        table.on('tool(logisticsTable)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
                $.get("/Logistics/del",{"id":data.id},function (e) {
                    layer.confirm('确定删除？', function (index) {
                        if (e.code==0) {
                            obj.del();
                            layer.close(index);
                            notify.success(e.msg)
                        }else {
                            notify.error(e.msg)
                        }
                    });
                })
            }
        });
    });
</script>
</html>